package br.com.io.dao;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;


import br.com.io.modelo.Cliente;
import br.com.io.modelo.Ocorrencia;

public class OcorrenciaDao {

	/**
	 * @param args
	 */
	
	private Session session;
	
	public OcorrenciaDao(Session session){
      //  super(session,Cliente.class);
		this.session = session;
    }
	
	public List<Ocorrencia> buscaOcorrencia(){
        Criteria c = getSession().createCriteria(Ocorrencia.class);
       // c.add(Restrictions.ilike("ocorrencia", ocorrencia));
        return c.list();
    }
	
	
    
  /*
    
    public List<Cliente> buscaClientes(String nome){
        Criteria c = getSession().createCriteria(Cliente.class);
        c.add(Restrictions.ilike("nomeCli", nome));
        return c.list();
    }
     
     public List<Cliente> buscaClientePorNomeEEmail(String nome, String email){
         
         Criteria c = getSession().createCriteria(Cliente.class);
         c.add(Restrictions.ilike("nomeCli", nome));
         c.add(Restrictions.ilike("email", email));
         return c.list();
              
         
   }
     
     public List<Cliente> buscaClienteOr(String nome, String email){
         Criteria c = getSession().createCriteria(Cliente.class);
         Criterion c1 = Restrictions.ilike("nomeCli", nome);
         Criterion c2 = Restrictions.ilike("email", email);
         Criterion c3 = Restrictions.or(c1, c2);
         c.add(c3);
         return c.list();
     }
    
     public int counTotalClientes(){
         Criteria c = getSession().createCriteria(Cliente.class);
         c.setProjection(Projections.rowCount());
         return(Integer) (c.uniqueResult());
         
     }

*/
   
     public Session getSession() {
		return session;
	}

	public void setSession(Session session) {
		this.session = session;
	}

	public void salva(Ocorrencia oco){
 		
 		session.save(oco);
 	}
	

}
